<?php

class LinestopsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
      
		$line = new Application_Model_DbTable_Lines();
		$result = $line->showLines();
		$this->view->line = $result;
		
		if ($this->getRequest()->isPost())
			{
				$id = $this->getRequest()->getPost('lines');
				$linestops = new Application_Model_DbTable_Linestops();
				$result = $linestops->getLineStops($id);
				$this->view->linestops = $result;
			}
		
	}

    public function addlinestopAction()
    {
        $form = new Application_Form_Linestop();
		$form->submit->setLabel('Add');
		$this->view->form = $form;
		
		if ($this->getRequest()->isPost()) {
				$formData = $this->getRequest()->getPost();
			if ($form->isValid($formData)) {
					$linestops = new Application_Model_DbTable_Linestops();
						$linestops->addLineStops((int)$form->getValue('lines'), (int)$form->getValue('stops'));
				$this->_helper->redirector('index');
			} 
	
		}
	}

    public function deletelinestopAction()
    {
		$form = new Application_Form_Linestop();
		$form->submit->setLabel('Delete');
		$this->view->form = $form;
		
		if ($this->getRequest()->isPost()) {
				$formData = $this->getRequest()->getPost();
			if ($form->isValid($formData)) {
					$linestops = new Application_Model_DbTable_Linestops();
					$linestops->deleteLineStops($form->getValue('lines'), $form->getValue('stops'));
					$this->_helper->redirector('index');
			} 
			
		} 
    }


}





